package Dinamica;

import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Cajas {
	
	//1 7 9 , 6 3 5 , 10 5 5
	//4
	public static List<int[]> caras(int [][] cajas){
		Comparator<int[]> c=new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				int a=o1[0]-o2[0];
				return a==0?o1[1]-o2[1]:a;
			}
		};
		Set<int[]> caras=new TreeSet<int[]>(c); 
		for (int[] it : cajas) {
			caras.add(new int[]{Math.min(it[0], it[1]), Math.max(it[0], it[1]), it[2]});
			caras.add(new int[]{Math.min(it[0], it[2]), Math.max(it[0], it[2]), it[1]});
			caras.add(new int[]{Math.min(it[2], it[1]), Math.max(it[2], it[1]), it[0]});
		}
		return new LinkedList<int[]>(caras);
	}
	
	public static int dinamica(List<int[]> caras){
		int maxa=0,maxb=0;
		for (int[] it : caras) {
			maxa=Math.max(it[0], maxa);
			maxb=Math.max(it[1], maxb);
		}
		int[][] memo=new int[maxa+2][maxb+2];
		for (int[] it : caras) {
			for (int i = it[0]+1; i < maxa+2; i++) {
				for (int j = it[1]+1; j < maxb+2; j++) {
					memo[i][j]=Math.max(memo[i][j], memo[it[0]][it[1]]+it[2]);
				}
			}
			System.out.println(Arrays.toString(it));
			for (int i = 0; i < memo.length; i++) {
				System.out.println(Arrays.toString(memo[i]));
			}
			System.out.println();
			
		
		}
		return (int)(Math.random()*100);
	}

	public static void main(String[] args) throws Throwable{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String ln;
		int [][] cajas;
		while(true){
			int n=Integer.parseInt(br.readLine().trim());
			int[][] c=new int[n][3];
			for (int i = 0; i < n; i++) {
				StringTokenizer st=new StringTokenizer(br.readLine());
				c[i][0]=Integer.parseInt(st.nextToken());
				c[i][1]=Integer.parseInt(st.nextToken());
				c[i][2]=Integer.parseInt(st.nextToken());
			}
			System.out.println(dinamica(caras(c)));
			System.out.println();
		}
		
	}
	
	
	
	

}
